home *** CD-ROM | disk | FTP | other *** search
- /******************************************************************/
- /* */
- /* TurboCAD for Windows */
- /* Copyright (c) 1993 - 2001 */
- /* International Microcomputer Software, Inc. */
- /* (IMSI) */
- /* All rights reserved. */
- /* */
- /******************************************************************/
- // BlockInsertDialog.cpp : implementation file
- //
-
- #include "stdafx.h"
- #include "SDKDemo.h"
- #include "BlockInsertDialog.h"
-
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
-
- /////////////////////////////////////////////////////////////////////////////
- // CBlockInsertDialog dialog
-
-
- CBlockInsertDialog::CBlockInsertDialog(IDrawing* pIDrawing, CWnd* pParent /*=NULL*/) :
- CDialog(CBlockInsertDialog::IDD, pParent),
- m_pBlocks(NULL)
- {
- //{{AFX_DATA_INIT(CBlockInsertDialog)
- m_strBlockName = _T("");
- //}}AFX_DATA_INIT
-
- if (pIDrawing != NULL)
- {
- Blocks* pBlocks = NULL;
- HRESULT hRes = pIDrawing->get_Blocks(&pBlocks);
- if (SUCCEEDED(hRes))
- {
- long lCount = 0;
- hRes = pBlocks->get_Count(&lCount);
- if (SUCCEEDED(hRes) && lCount > 0)
- {
- m_pBlocks = pBlocks;
- return;
- }
- pBlocks->Release();
- }
- }
- }
-
- CBlockInsertDialog::~CBlockInsertDialog()
- {
- if (m_pBlocks != NULL)
- m_pBlocks->Release();
- }
-
- void CBlockInsertDialog::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(CBlockInsertDialog)
- DDX_LBString(pDX, IDC_BLOCKS, m_strBlockName);
- //}}AFX_DATA_MAP
- }
-
- BOOL CBlockInsertDialog::OnInitDialog()
- {
- CDialog::OnInitDialog();
-
- BOOL bSuccess = FALSE;
- if (m_pBlocks != NULL)
- {
- long lCount = 0;
- HRESULT hRes = m_pBlocks->get_Count(&lCount);
- if (SUCCEEDED(hRes) && lCount > 0)
- {
- CListBox* pList = (CListBox*)GetDlgItem(IDC_BLOCKS);
- for (long i = 0; i < lCount; ++i)
- {
- Block* pBlock = NULL;
- COleVariant varIndex(i);
- hRes = m_pBlocks->get_Item(&varIndex, &pBlock);
- if (SUCCEEDED(hRes))
- {
- BSTR bstrName = NULL;
- hRes = pBlock->get_Name(&bstrName);
- if (SUCCEEDED(hRes))
- {
- CString str(bstrName);
- SysFreeString(bstrName);
-
- if (pList->AddString(str) != LB_ERR)
- bSuccess = TRUE;
- }
- }
- }
- }
- }
- if (!bSuccess)
- EndDialog(IDCANCEL);
- return TRUE;
- }
-
- BEGIN_MESSAGE_MAP(CBlockInsertDialog, CDialog)
- //{{AFX_MSG_MAP(CBlockInsertDialog)
- ON_LBN_DBLCLK(IDC_BLOCKS, OnDblclkBlocks)
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
-
- /////////////////////////////////////////////////////////////////////////////
- // CBlockInsertDialog message handlers
-
- void CBlockInsertDialog::OnDblclkBlocks()
- {
- UpdateData(TRUE);
- EndDialog(IDOK);
- }
-
-